import {defineStore} from 'pinia'
import {selectArticleGroup} from "@/api/artcle/article";
import {useUserStore} from "@/store/modules/user";
const userStore =  useUserStore();

export  const useArticleStore = defineStore("article",{
     persist: true, //开启持久化
    state: () => ({
        order:"",
        group:{},
        userid:userStore.id ||1,
        isData:false,
        article:null
    }),
    getters:{
        getGroup:(state)=>{
            return state.group
        },
        getArticle:(state)=>{
            return state.article
        },
        getType:(state)=>{
            return state.type
        },
    },
    actions: {
        getArticleGroup(){
             return new Promise((resolve, reject) => {
                 selectArticleGroup().then(res => {
                     this.group = res.data
                     resolve()
                 }).catch(error => {
                     reject(error)
                 })
             })
        },
    },
})
